package com.mapproject.industrymap.service.impl;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mapproject.industrymap.entity.BaseInfoEntity;
import com.mapproject.industrymap.mapper.BaseInfoMapper;
import com.mapproject.industrymap.service.FoodassetsBaseInfoService;
import com.mapproject.industrymap.utils.ReturnValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
@Service
public class FoodassetsBaseInfoServiceImpl implements FoodassetsBaseInfoService {
    @Autowired
    BaseInfoMapper baseinfomapper;

    /**
     * 获取基础信息表数据
     * @param rowguid
     * @return
     */
    public String retrievedata(String rowguid){
        String  result=baseinfomapper.getdata(rowguid);
        return result;
    }
    public ReturnValue updatedata(BaseInfoEntity baseinfoentity){
        BaseInfoEntity newbase=baseinfoentity;
        int propertyresult=0;
        try{
            propertyresult=baseinfomapper.updatedata(newbase);
            String geom= JSON.toJSONString(baseinfoentity.getGeom());
            String rownum=newbase.getRowguid();
            int geomresult=baseinfomapper.updategeommetry(rownum,geom);
            return new ReturnValue(200,"更新属性数据与几何",geomresult);
        }catch (Exception ex){
            return new ReturnValue(200,"仅更新属性数据",propertyresult);
        }


    }
    public ReturnValue queryname(){
        try {
            String result= baseinfomapper.queryname();
            return new ReturnValue(200,"查询成功",JSON.parse(result));

        }catch (Exception ex){
            String result= baseinfomapper.queryname();
            return new ReturnValue(500,"查询失败",ex);
        }

    }
}
